// pages/consult/consultDetails/consultDetails.js
let app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    consultantEvaluations:'',
    url:'',
    id:0,
    consultant:'',
    pageNum:1,
    pageSize:3,
    course:'',
    chargingStandards:'',
    consultantId:1,
    psychReply:'',
    myconsult:'',
    user:'',
    
  },
  zhuanwen(){
    wx.navigateTo({
      url: 'url',
    })
  },
  sixin(){
    wx.showModal({
      title: '确认发送私信吗？',
      content: '我们秒回哦，亲',
      complete: (res) => {
        if (res.cancel) {
         
        }
    
        if (res.confirm) {
         wx.navigateTo({
           url: '/pages/home/zaixiankefu/zaixiankefu',
         })
            }
      }
    })

  },
  zixun(e){
    wx.showModal({
      title: '确认咨询吗？',
      content: '我们很权威哦，亲',
      complete: (res) => {
        if (res.cancel) {
         
        }
    
        if (res.confirm) {
          
          wx.request({
            url: this.data.url+'MyConsult',
            method:"POST",
            data:{
              consultContent:this.data.course[this.data.id].courseName,
              consultTime:new Date,
              userId:this.data.user.id,
              consultantId:this.data.consultantId,
              status:'未完成',
              assessStatus:'未评价'
            }
          })
            }
      }
    })

  },
  getconsultantEvaluations(){
    wx.request({
      url: this.data.url+"consultantEvaluation/consultantEvaluations",
      data:{
        consultantId:this.data.id
      },
      success:resp=>{
console.log(resp.data.data);
       this.setData({
        consultantEvaluations:resp.data.data
       } )
      }
    })
  },
  getpsychReply(){
    wx.request({
      url: this.data.url+'psychReply/all',
      method:"GET",
      data:{
        pageNum: this.data.pageNum,
        pageSize: this.data.pageSize 
      },
      success:r=>{
        console.log(r.data.data.list);
        this.setData({
          psychReply:r.data.data.list
        })
      }
    })
  },
  getchargingStandards(){
    wx.request({
      url: this.data.url+'chargingStandards',
      method:"GET",
      data:{
        consultantId:this.data.id, // 将id作为参数传递
        pageNum: this.data.pageNum,
        pageSize: this.data.pageSize 
      },
      success:re=>{
        console.log(re.data.data);
        this.setData({
          chargingStandards:re.data.data
        })
      }
    })
  },
  getCourse(){
    wx.request({
      url: this.data.url+'course/conid',
      method:"GET",
      data:{
      id: this.data.id, // 将id作为参数传递
      pageNum: this.data.pageNum,
      pageSize: this.data.pageSize 
      },
      success:res=>{
        console.log(res.data.data.list);
        this.setData({
          course:res.data.data.list
        })
      }
    })
  },
  zhuandaokec(){
    wx.navigateTo({
      url: '/pages/consult/consultDetailes/gdkc/gdkc',
    })
      },
  getConsultant(){
    wx.request({
      url: this.data.url+'Consultant/'+this.data.id,
      success:resp=>{
        console.log(resp.data.data);
        this.setData({
          consultant:resp.data.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      user:wx.getStorageSync('user')
    })
// console.log('咨询师的编号为：'+options.id);
this.setData({
  id:options.id,
  url:app.globalData.url
})
//调方法查信息
this.getConsultant();
this.getCourse();
this.getchargingStandards();
this.getpsychReply();
this.getconsultantEvaluations();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})